package com.app.base.service.common.service.impl;

import com.app.base.config.mq.RabbitConfig;
import com.app.base.service.common.service.CommonService;
import com.app.base.utlis.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class CommonServiceImpl implements CommonService {

    @Resource
    private RabbitTemplate rabbitTemplate;

    @Override
    public Result verificationCode(String phone) {
        try{
            String exchangeName = RabbitConfig.DIRECT_EXCHANGE;
            String routingKey = "";
            rabbitTemplate.convertAndSend(exchangeName,routingKey,phone);
            return Result.ok();
        }catch(Exception e){
            log.error(e.getMessage());
            return Result.error(e.getMessage());
        }
    }
}
